package com.mail.model.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * 所有分页查询返回结果的vo对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult implements Serializable {

    private Long total = 0l;//总记录数
    private Long pageSize=10l;//页大小
    private Long totalPage = 0l;//总页数
    private Long pageNum=1l;//当前页码
    private List<?> list = Collections.emptyList(); //列表

    public PageResult(Long page,Long pageSize,Long counts,List list) {
        this.pageNum = page;
        this.pageSize = pageSize;
        this.list = list;
        this.total = counts;
        this.totalPage = counts % pageSize == 0 ? counts / pageSize : counts / pageSize + 1;
    }

    public PageResult(Long page, Long pageSize) {
        this.pageNum = page;
        this.pageSize = pageSize;
    }
}